#include "Simulator.h"

Simulator::Simulator(int sizeX, int sizeY) 
{ 
    universe = new Universe(8,8);
    scheduler = new Scheduler(universe);
    registerer = new  SimulatorRegister(universe, scheduler);
}

Simulator::~Simulator()
{
    delete universe;   
    delete scheduler;
    delete registerer;
}

bool Simulator::addGhost(Ghost * ghost)
{ 
    /* add to field and register it */ 
    ghost->bind(registerer);

	return true;
}

void Simulator::simulateSingleTimeFrame()
{
    scheduler->executeTimeFrame();
}


void Simulator::printUniverse()
{
    for(int i = universe->getYsize() -1 ; i >= 0 ; --i)
    {
        for(int j = 0 ; j < universe->getXsize() ; ++j)
            if(universe->getElementAt(Position(j, i)))
                std::cout << universe->getElementAt(Position(j, i))->getID() << " ";
            else
                std::cout << "0" << " ";
        std::cout << std::endl;
    }
}

